import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../../module_browser/viewmodel/before_browser.dart';
import '../../model/dapp_hot_model.dart';
import '../dapp_empty.dart';
import '../dapp_list.dart';

class DAppListPage extends StatelessWidget {
  final List<BookMarkListModel> list;
  // final List<int> list;
  final bool hasMore;

  const DAppListPage({super.key, required this.list, this.hasMore = false});

  @override
  Widget build(BuildContext context) {
    // super.build(context);
    return ListView.builder(
        padding: EdgeInsets.only(top: 0),
        physics: const ClampingScrollPhysics(),
        itemCount: list.length + 1,
        itemBuilder: (context, index) {
          if (list.isEmpty) {
            return Container(
              padding: EdgeInsets.only(top: 30.w),
              color: Color.fromRGBO(255, 255, 255, 1),
              child: DAppEmpty(title: 'Empty data'),
            );
          }
          if (index == list.length) {
            return Container(
              height: 70.w,
              alignment: Alignment.center,
              child: Text(
                'Already at the bottom',
                style: TextStyle(fontSize: 14.sp, color: Color.fromRGBO(190, 189, 202, 1), fontWeight: FontWeight.w400),
              ),
            );
          }
          var item = list[index];
          return DAppList(
              name: item.bookmark.name,
              image: item.bookmark.logo,
              statement: item.bookmark.statement,
              introduce: item.bookmark.introduce as String,
              onClick: () {
                doGotoBrowser(context: context, webUrl: item.bookmark.url);
              });
        });
  }
}
